<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef" tableRef='payOrderDetail'>
      <template #summaryCell="{ column, record, rowIndex }">
          <div>{{ column.dataIndex == "pay_order_id" ? "合计" : record[column.dataIndex] }}</div>
      </template>
    </ma-crud>
  </div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import financialPayOrderDetail from '@/api/financial/financialPayOrderDetail'
import { Message } from '@arco-design/web-vue'
import tool from '@/utils/tool'
import * as common from '@/utils/common'

const crudRef = ref()


const numberOperation = (newValue, id, numberName) => {
  financialPayOrderDetail.numberOperation({ id, numberName, numberValue: newValue }).then( res => {
    res.success && Message.success(res.message)
  }).catch( e => { console.log(e) } )
}

const switchStatus = (statusValue, id, statusName) => {
  financialPayOrderDetail.changeStatus({ id, statusName, statusValue }).then( res => {
    res.success && Message.success(res.message)
  }).catch( e => { console.log(e) } )
}


const options = reactive({
  id: 'flyos_financial_pay_order_detail',
  rowSelection: {
    showCheckedAll: true
  },
  pk: 'id',
  operationColumn: false,
  operationWidth: 160,
  formOption: {
    viewType: 'modal',
    width: 600
  },
  showSummary: true,
  summary: [
		{
			dataIndex: "pay_price",
			action: "sum",
		},
		
	],
  api: financialPayOrderDetail.getList,
  recycleApi: financialPayOrderDetail.getRecycleList,
  add: {
    show: false,
    api: financialPayOrderDetail.save,
    auth: ['financial:payOrderDetail:save']
  },
  edit: {
    show: false,
    api: financialPayOrderDetail.update,
    auth: ['financial:payOrderDetail:update']
  },
  delete: {
    show: false,
    api: financialPayOrderDetail.deletes,
    auth: ['financial:payOrderDetail:delete'],
    realApi: financialPayOrderDetail.realDeletes,
    realAuth: ['financial:payOrderDetail:realDeletes']
  },
  recovery: {
    show: false,
    api: financialPayOrderDetail.recoverys,
    auth: ['financial:payOrderDetail:recovery']
  },
  import: {
    show: false,
    url: 'financial/payOrderDetail/import',
    templateUrl: 'financial/payOrderDetail/downloadTemplate',
    auth: ['financial:payOrderDetail:import']
  },
  exports: {
    show: true,
    url: 'financial/payOrderDetail/export',
    auth: ['financial:payOrderDetail:export']
  }
})

const columns = reactive([
  {
    title: "",
    dataIndex: "id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    commonRules: {
      required: true,
      message: "请输入"
    }
  },
  {
    title: "支付订单号",
    dataIndex: "pay_order_id",
    formType: "input",
    search: true
  },
  
  {
    title: "计算规则",
    dataIndex: "chi_price_role",
    formType: "input",
    // search: true
  },
  {
    title: "金额",
    dataIndex: "pay_price",
    formType: "input",
    // search: true
  },
  {
    title: "费用名称",
    dataIndex: "pay_name",
    formType: "input",
    search: true
  },
  {
    title: "计费箱号",
    dataIndex: "box",
    formType: "input",
    search: true
  },
  {
    title: "装车号",
    dataIndex: "car_no",
    formType: "input",
    search: true
  },
  {
    title: "创建时间",
    dataIndex: "created_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "更新时间",
    dataIndex: "updated_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "删除时间",
    dataIndex: "deleted_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "创建者",
    dataIndex: "created_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "更新者",
    dataIndex: "updated_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  }
])
defineExpose({
    crudRef
  })
</script>
<script> export default { name: 'financial:payOrderDetail' } </script>